package com.常用类.作业;

public class 注册事件 {
    public static void main(String[] args) {
        user jeak = new user("jeak", "1659298868@qq.com", 164959);
        System.out.println(jeak);

    }

}

class user {
    private String name;
    private String email;
    private int password;

    public user(String name, String email, int password) {
        setName(name);
        setEmail(email);
        setPassword(password);
        System.out.println("ok~~~~");
    }

    public void setName(String name) {
        if (!(name.length() <= 4 && name.length() >= 2)) {
            throw new RuntimeException("长度不够");
        }
        this.name = name;
    }

    public void setEmail(String email) {

        if (!(email.indexOf(".") != -1 && email.indexOf("@") != -1 && (email.indexOf(".") - email.indexOf("@") > 0))) {
            throw new RuntimeException("电子邮件格式错误");
        }
        this.email = email;
    }

    public void setPassword(int password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "user{" +
                "name='" + name + '\'' +
                ", email='" + email + '\'' +
                ", password=" + password +
                '}';
    }
}
